External context support in RichText / RichEdit

git-svn-id: svn://ultimatepp.org/upp/trunk@972 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
rylek 2009-03-18 01:03:40 +00:00
parent 8085dfdde4
commit 178e234cf7
23 changed files with 173 additions and 52 deletions

View file

@ -196,7 +196,7 @@ Callback callback2(Object *object, R (O::*method)(A, B), T1 arg1, T2 arg2) {
template <class Object, class R, class O, class A, class B, class T1, class T2> template <class Object, class R, class O, class A, class B, class T1, class T2>
Callback callback2(const Object *object, R (O::*method)(A, B) const, T1 arg1, T2 arg2) { Callback callback2(const Object *object, R (O::*method)(A, B) const, T1 arg1, T2 arg2) {
return Callback(new CallbackMethodActionArg2<Object, R (O::*)(A, B) const, T1, T2> return Callback(new CallbackMethodActionArg2<const Object, R (O::*)(A, B) const, T1, T2>
(object, method, arg1, arg2)); (object, method, arg1, arg2));
} }

View file

@ -343,6 +343,8 @@ public:
const T& Get(const Maker& m); const T& Get(const Maker& m);
void Clear();
void ClearCounters(); void ClearCounters();
int GetFoundSize() const { return foundsize; } int GetFoundSize() const { return foundsize; }
int GetNewSize() const { return newsize; } int GetNewSize() const { return newsize; }
@ -397,6 +399,17 @@ void LRUCache<T, K>::Shrink(int maxsize)
} }
} }
template <class T, class K>
void LRUCache<T, K>::Clear()
{
head = -1;
size = 0;
count = 0;
newsize = foundsize = 0;
key.Clear();
data.Clear();
}
template <class T, class K> template <class T, class K>
void LRUCache<T, K>::ClearCounters() void LRUCache<T, K>::ClearCounters()
{ {

View file

@ -141,6 +141,7 @@ struct ImageMaker {
Image MakeImage(const ImageMaker& m); Image MakeImage(const ImageMaker& m);
Image MakeImage(const Image& image, Image (*make)(const Image& image)); Image MakeImage(const Image& image, Image (*make)(const Image& image));
void ClearMakeImageCache();
void SetMakeImageCacheSize(int m); void SetMakeImageCacheSize(int m);
void SetMakeImageCacheMax(int m); void SetMakeImageCacheMax(int m);

View file

@ -17,7 +17,7 @@ struct scImageMaker : LRUCache<Image>::Maker {
bool paintonly; bool paintonly;
virtual String Key() const { virtual String Key() const {
String q = m->Key(); // String q = m->Key();
return m->Key(); return m->Key();
} }
virtual int Make(Image& object) const { virtual int Make(Image& object) const {
@ -33,6 +33,11 @@ struct scImageMaker : LRUCache<Image>::Maker {
static int sMaxSize; static int sMaxSize;
static int sMaxSizeMax = 4000000; static int sMaxSizeMax = 4000000;
void ClearMakeImageCache()
{
sImageCache().Clear();
}
void SetMakeImageCacheMax(int m) void SetMakeImageCacheMax(int m)
{ {
sMaxSizeMax = m; sMaxSizeMax = m;

View file

@ -148,7 +148,7 @@ Report& Report::Landscape()
return *this; return *this;
} }
void Report::Put(const RichText& txt) void Report::Put(const RichText& txt, void *context)
{ {
PageY py(pagei, y); PageY py(pagei, y);
PaintInfo paintinfo; PaintInfo paintinfo;
@ -156,6 +156,7 @@ void Report::Put(const RichText& txt)
paintinfo.bottom = PageY(INT_MAX, INT_MAX); paintinfo.bottom = PageY(INT_MAX, INT_MAX);
paintinfo.indexentry = Null; paintinfo.indexentry = Null;
paintinfo.hyperlink = Null; paintinfo.hyperlink = Null;
paintinfo.context = context;
txt.Paint(*this, py, GetPageRect(), paintinfo); txt.Paint(*this, py, GetPageRect(), paintinfo);
py = txt.GetHeight(py, GetPageRect()); py = txt.GetHeight(py, GetPageRect());
Page(py.page); Page(py.page);

View file

@ -45,7 +45,7 @@ public:
void NewPage() { Page(pagei + 1); } void NewPage() { Page(pagei + 1); }
void Put(const RichText& txt); void Put(const RichText& txt, void *context = NULL);
void Put(const char *qtf); void Put(const char *qtf);
Report& operator<<(const char *qtf) { Put(qtf); return *this; } Report& operator<<(const char *qtf) { Put(qtf); return *this; }

View file

@ -112,6 +112,7 @@ void RichEdit::Paint(Draw& w)
DrawFrame(w, tr.left, i * (pw.size.cy + 3) + 1 - sb, DrawFrame(w, tr.left, i * (pw.size.cy + 3) + 1 - sb,
pw.size.cx + 2, pw.size.cy + 2, SColorShadow); pw.size.cx + 2, pw.size.cy + 2, SColorShadow);
PaintInfo pi; PaintInfo pi;
pi.context = context;
pi.zoom = zoom; pi.zoom = zoom;
pi.top = GetPageY(sb); pi.top = GetPageY(sb);
pi.bottom = GetPageY(sb + sz.cy); pi.bottom = GetPageY(sb + sz.cy);
@ -592,6 +593,8 @@ RichEdit::RichEdit()
zoom = 100; zoom = 100;
Clear(); Clear();
context = NULL;
nolinks = false; nolinks = false;
showcodes = LtBlue; showcodes = LtBlue;

View file

@ -83,7 +83,7 @@ bool RichEdit::Key(dword key, int count)
NextUndo(); NextUndo();
objectpos = c; objectpos = c;
RichObject o = object; RichObject o = object;
o.DefaultAction(); o.DefaultAction(context);
if(o.GetSerialId() != object.GetSerialId()) if(o.GetSerialId() != object.GetSerialId())
ReplaceObject(o); ReplaceObject(o);
return true; return true;

View file

@ -277,7 +277,7 @@ void RichEdit::InsertObject(int type)
RichObjectType& richtype = RichObject::GetType(type); RichObjectType& richtype = RichObject::GetType(type);
RichObject object = RichObject(&richtype, Value()); RichObject object = RichObject(&richtype, Value());
RichObject o = object; RichObject o = object;
o.DefaultAction(); o.DefaultAction(context);
if(o.GetSerialId() != object.GetSerialId()) { if(o.GetSerialId() != object.GetSerialId()) {
RichText::FormatInfo finfo = GetFormatInfo(); RichText::FormatInfo finfo = GetFormatInfo();
RemoveSelection(); RemoveSelection();

View file

@ -208,7 +208,7 @@ void RichEdit::RightDown(Point p, dword flags)
object = GetObject(); object = GetObject();
if(!object) return; if(!object) return;
o = object; o = object;
o.Menu(menu); o.Menu(menu, context);
if(!menu.IsEmpty()) if(!menu.IsEmpty())
menu.Separator(); menu.Separator();
menu.Add(t_("Object position.."), THISBACK(AdjustObjectSize)); menu.Add(t_("Object position.."), THISBACK(AdjustObjectSize));
@ -287,7 +287,7 @@ void RichEdit::LeftDouble(Point p, dword flags)
RichObject object = GetObject(); RichObject object = GetObject();
if(!object) return; if(!object) return;
RichObject o = object; RichObject o = object;
o.DefaultAction(); o.DefaultAction(context);
if(object.GetSerialId() != o.GetSerialId()) if(object.GetSerialId() != o.GetSerialId())
ReplaceObject(o); ReplaceObject(o);
} }

View file

@ -147,6 +147,7 @@ public:
private: private:
void *context;
Size p_size; Size p_size;
bool sizetracking; bool sizetracking;
ScrollBar sb; ScrollBar sb;
@ -658,6 +659,7 @@ public:
RichEdit& Unit(int u) { unit = u; Refresh(); return *this; } RichEdit& Unit(int u) { unit = u; Refresh(); return *this; }
RichEdit& SpellCheck(bool b) { spellcheck = b; Refresh(); return *this; } RichEdit& SpellCheck(bool b) { spellcheck = b; Refresh(); return *this; }
RichEdit& SetZoom(int z) { zoom = z; Refresh(); return *this; } RichEdit& SetZoom(int z) { zoom = z; Refresh(); return *this; }
RichEdit& SetContext(void *ctx) { context = ctx; Refresh(); return *this; }
struct UndoInfo { struct UndoInfo {
int undoserial; int undoserial;

View file

@ -1,3 +1,4 @@
PREMULTIPLIED
IMAGE_ID(RightTab) IMAGE_ID(RightTab)
IMAGE_ID(RightTabTrack) IMAGE_ID(RightTabTrack)
IMAGE_ID(LeftTab) IMAGE_ID(LeftTab)

View file

@ -137,7 +137,7 @@ LAYOUT(CreateTableLayout, 164, 88)
ITEM(Button, cancel, SetLabel(t_("Cancel")).LeftPosZ(92, 64).TopPosZ(56, 24)) ITEM(Button, cancel, SetLabel(t_("Cancel")).LeftPosZ(92, 64).TopPosZ(56, 24))
END_LAYOUT END_LAYOUT
LAYOUT(TablePropertiesLayout, 300, 168) LAYOUT(TablePropertiesLayout, 300, 188)
ITEM(Label, dv___0, SetLabel(t_("Before")).LeftPosZ(8, 60).TopPosZ(8, 19)) ITEM(Label, dv___0, SetLabel(t_("Before")).LeftPosZ(8, 60).TopPosZ(8, 19))
ITEM(UnitEdit, before, LeftPosZ(72, 68).TopPosZ(8, 19)) ITEM(UnitEdit, before, LeftPosZ(72, 68).TopPosZ(8, 19))
ITEM(Label, dv___2, SetLabel(t_("After")).LeftPosZ(160, 60).TopPosZ(8, 19)) ITEM(Label, dv___2, SetLabel(t_("After")).LeftPosZ(160, 60).TopPosZ(8, 19))
@ -154,11 +154,14 @@ LAYOUT(TablePropertiesLayout, 300, 168)
ITEM(UnitEdit, grid, LeftPosZ(72, 68).TopPosZ(80, 19)) ITEM(UnitEdit, grid, LeftPosZ(72, 68).TopPosZ(80, 19))
ITEM(Label, dv___14, SetLabel(t_("color")).LeftPosZ(160, 56).TopPosZ(80, 19)) ITEM(Label, dv___14, SetLabel(t_("color")).LeftPosZ(160, 56).TopPosZ(80, 19))
ITEM(ColorPusher, gridcolor, LeftPosZ(224, 68).TopPosZ(80, 19)) ITEM(ColorPusher, gridcolor, LeftPosZ(224, 68).TopPosZ(80, 19))
ITEM(Option, equalize, SetLabel(t_("Equalize")).LeftPosZ(8, 64).TopPosZ(108, 20)) ITEM(Label, dv___16, SetLabel(t_("Header")).LeftPosZ(8, 60).TopPosZ(106, 19))
ITEM(EditString, ratios, LeftPosZ(72, 220).TopPosZ(108, 19)) ITEM(EditIntSpin, header, LeftPosZ(72, 68).TopPosZ(106, 19))
ITEM(Button, destroy, SetLabel(t_("Remove table")).LeftPosZ(8, 96).TopPosZ(136, 24)) ITEM(Option, keep, SetLabel(t_("Keep rows together")).LeftPosZ(158, 136).TopPosZ(107, 16))
ITEM(Button, ok, SetLabel(t_("OK")).LeftPosZ(160, 64).TopPosZ(136, 24)) ITEM(Option, equalize, SetLabel(t_("Equalize")).LeftPosZ(8, 64).TopPosZ(130, 20))
ITEM(Button, cancel, SetLabel(t_("Cancel")).LeftPosZ(228, 64).TopPosZ(136, 24)) ITEM(EditString, ratios, LeftPosZ(72, 220).TopPosZ(130, 19))
ITEM(Button, destroy, SetLabel(t_("Remove table")).LeftPosZ(8, 96).TopPosZ(158, 24))
ITEM(Button, ok, SetLabel(t_("OK")).LeftPosZ(160, 64).TopPosZ(158, 24))
ITEM(Button, cancel, SetLabel(t_("Cancel")).LeftPosZ(228, 64).TopPosZ(158, 24))
END_LAYOUT END_LAYOUT
LAYOUT(SplitCellLayout, 148, 92) LAYOUT(SplitCellLayout, 148, 92)

View file

@ -18,7 +18,7 @@ void RichEdit::InsertTable()
return; return;
WithCreateTableLayout<TopWindow> dlg; WithCreateTableLayout<TopWindow> dlg;
CtrlLayoutOKCancel(dlg, t_("Insert table")); CtrlLayoutOKCancel(dlg, t_("Insert table"));
dlg.header = true; dlg.header = false;
dlg.columns <<= 2; dlg.columns <<= 2;
dlg.columns.MinMax(1, 20); dlg.columns.MinMax(1, 20);
dlg.ActiveFocus(dlg.columns); dlg.ActiveFocus(dlg.columns);
@ -111,7 +111,10 @@ void RichEdit::TableProps()
Advn(r, dlg.frame.SetUnit(unit), fmt.frame); Advn(r, dlg.frame.SetUnit(unit), fmt.frame);
r(dlg.framecolor, fmt.framecolor); r(dlg.framecolor, fmt.framecolor);
Advn(r, dlg.grid.SetUnit(unit), fmt.grid); Advn(r, dlg.grid.SetUnit(unit), fmt.grid);
Advn(r, dlg.header, fmt.header);
Advn(r, dlg.keep, fmt.keep);
r(dlg.gridcolor, fmt.gridcolor); r(dlg.gridcolor, fmt.gridcolor);
for(;;) {
switch(dlg.Run()) { switch(dlg.Run()) {
case IDCANCEL: case IDCANCEL:
return; return;
@ -121,6 +124,23 @@ void RichEdit::TableProps()
return; return;
default: default:
r.Retrieve(); r.Retrieve();
const RichTable& tbl = text.GetConstTable(cursorp.table);
bool valid = true;
Point violator(0, 0);
int vspan = 0;
for(int rw = 0; valid && rw < fmt.header && rw < tbl.GetRows(); rw++)
for(int co = 0; valid && co < tbl.GetColumns(); co++)
if(tbl(rw, co) && (vspan = tbl[rw][co].vspan) + rw > fmt.header) {
valid = false;
violator.x = co;
violator.y = rw;
break;
}
if(!valid) {
Exclamation(NFormat(t_("Invalid header row count %d, cell at rw %d, co %d has vspan = %d."),
fmt.header, violator.y + 1, violator.x + 1, vspan));
continue;
}
NextUndo(); NextUndo();
SaveTableFormat(cursorp.table); SaveTableFormat(cursorp.table);
if(dlg.equalize) { if(dlg.equalize) {
@ -129,8 +149,10 @@ void RichEdit::TableProps()
fmt.column[i] = i < r.GetCount() ? max(atoi(r[i]), 1) : 1; fmt.column[i] = i < r.GetCount() ? max(atoi(r[i]), 1) : 1;
} }
text.SetTableFormat(cursorp.table, fmt); text.SetTableFormat(cursorp.table, fmt);
}
Finish(); Finish();
return;
}
}
} }
bool RichEdit::RemoveSpecial(int ll, int hh, bool back) bool RichEdit::RemoveSpecial(int ll, int hh, bool back)

View file

@ -10,12 +10,12 @@ String RichObjectType::GetCreateName() const
return Null; return Null;
} }
Size RichObjectType::GetDefaultSize(const Value& data, Size maxsize) const Size RichObjectType::StdDefaultSize(const Value& data, Size maxsize, void * context) const
{ {
if(IsNull(data)) return Size(0, 0); if(IsNull(data)) return Size(0, 0);
Size psz = GetPhysicalSize(data); Size psz = GetPhysicalSize(data, context);
if((psz.cx | psz.cy) == 0) if((psz.cx | psz.cy) == 0)
psz = 625 * GetPixelSize(data) / 100; psz = 625 * GetPixelSize(data, context) / 100;
Size sz; Size sz;
for(int i = 1; i < 10000; i++) { for(int i = 1; i < 10000; i++) {
sz = psz / i; sz = psz / i;
@ -25,6 +25,16 @@ Size RichObjectType::GetDefaultSize(const Value& data, Size maxsize) const
return sz; return sz;
} }
Size RichObjectType::GetDefaultSize(const Value& data, Size maxsize, void *context) const
{
return GetDefaultSize(data, maxsize);
}
Size RichObjectType::GetDefaultSize(const Value& data, Size maxsize) const
{
return StdDefaultSize(data, maxsize, NULL);
}
Value RichObjectType::Read(const String& s) const Value RichObjectType::Read(const String& s) const
{ {
return s; return s;
@ -55,20 +65,59 @@ String RichObjectType::GetClip(const Value& data, const String& fmt) const
return Null; return Null;
} }
void RichObjectType::Menu(Bar& bar, RichObject& data, void *context) const
{
Menu(bar, data);
}
void RichObjectType::Menu(Bar& bar, RichObject& data) const {} void RichObjectType::Menu(Bar& bar, RichObject& data) const {}
void RichObjectType::DefaultAction(RichObject& data, void *context) const
{
DefaultAction(data);
}
void RichObjectType::DefaultAction(RichObject& data) const {} void RichObjectType::DefaultAction(RichObject& data) const {}
Size RichObjectType::GetPhysicalSize(const Value& data, void *context) const
{
return GetPhysicalSize(data);
}
Size RichObjectType::GetPhysicalSize(const Value& data) const { return Size(0, 0); } Size RichObjectType::GetPhysicalSize(const Value& data) const { return Size(0, 0); }
Size RichObjectType::GetPixelSize(const Value& data, void *context) const
{
return GetPixelSize(data);
}
Size RichObjectType::GetPixelSize(const Value& data) const { return Size(1, 1); } Size RichObjectType::GetPixelSize(const Value& data) const { return Size(1, 1); }
void RichObjectType::Paint(const Value& data, Draw& w, Size sz, void *context) const
{
Paint(data, w, sz);
}
void RichObjectType::Paint(const Value& data, Draw& w, Size sz) const {} void RichObjectType::Paint(const Value& data, Draw& w, Size sz) const {}
Image RichObjectType::ToImage(const Value& data, Size sz) const Image RichObjectType::ToImage(const Value& data, Size sz) const
{
return ToImage(data, sz, NULL);
}
Image RichObjectType::ToImage(const Value& data, Size sz, void *context) const
{ {
ImageDraw w(sz); ImageDraw w(sz);
Paint(data, w, sz); Paint(data, w, sz, context);
return w; return w;
} }
String RichObjectType::GetLink(const Value& data, Point pt, Size sz) const String RichObjectType::GetLink(const Value& data, Point pt, Size sz) const
{
return GetLink(data, pt, sz, NULL);
}
String RichObjectType::GetLink(const Value& data, Point pt, Size sz, void *context) const
{ {
return Null; return Null;
} }
@ -105,10 +154,10 @@ void RichObject::Register(const char *name, RichObjectType *type)
Map().FindAdd(name, type); Map().FindAdd(name, type);
} }
void RichObject::Paint(Draw& w, Size sz) const void RichObject::Paint(Draw& w, Size sz, void *context) const
{ {
if(type) if(type)
type->Paint(data, w, sz); type->Paint(data, w, sz, context);
else { else {
w.DrawRect(sz, SColorFace()); w.DrawRect(sz, SColorFace());
DrawFrame(w, sz, SColorText()); DrawFrame(w, sz, SColorText());
@ -116,13 +165,13 @@ void RichObject::Paint(Draw& w, Size sz) const
} }
} }
Image RichObject::ToImage(Size sz) const Image RichObject::ToImage(Size sz, void *context) const
{ {
if(type) if(type)
return type->ToImage(data, sz); return type->ToImage(data, sz, context);
else { else {
ImageDraw w(sz); ImageDraw w(sz);
Paint(w, sz); Paint(w, sz, context);
return w; return w;
} }
} }

View file

@ -17,6 +17,7 @@ PaintInfo::PaintInfo()
highlight = Yellow(); highlight = Yellow();
indexentry = LtGreen(); indexentry = LtGreen();
coloroverride = false; coloroverride = false;
context = NULL;
} }
String RichPara::Number::AsText(const RichPara::NumberFormat& format) const String RichPara::Number::AsText(const RichPara::NumberFormat& format) const

View file

@ -122,6 +122,7 @@ bool RichPara::BreaksPage(PageY py, const Lines& pl, int i, const Rect& page) co
struct RichObjectImageMaker : ImageMaker { struct RichObjectImageMaker : ImageMaker {
RichObject object; RichObject object;
Size sz; Size sz;
void *context;
virtual String Key() const; virtual String Key() const;
virtual Image Make() const; virtual Image Make() const;
@ -134,6 +135,7 @@ String RichObjectImageMaker::Key() const
b.Cat((const char *)&id, sizeof(id)); b.Cat((const char *)&id, sizeof(id));
b.Cat((const char *)&sz.cx, sizeof(sz.cx)); b.Cat((const char *)&sz.cx, sizeof(sz.cx));
b.Cat((const char *)&sz.cy, sizeof(sz.cy)); b.Cat((const char *)&sz.cy, sizeof(sz.cy));
b.Cat((const char *)&context, sizeof(context));
return b; return b;
} }
@ -141,7 +143,7 @@ Image RichObjectImageMaker::Make() const
{ {
ImageDraw iw(sz); ImageDraw iw(sz);
iw.DrawRect(sz, SColorPaper()); iw.DrawRect(sz, SColorPaper());
object.Paint(iw, sz); object.Paint(iw, sz, context);
return iw; return iw;
} }
@ -247,10 +249,11 @@ void RichPara::Paint(PageDraw& pw, const Rect& page, PageY py, const PaintInfo&
RichObjectImageMaker im; RichObjectImageMaker im;
im.object = o; im.object = o;
im.sz = sz; im.sz = sz;
im.context = pi.context;
draw.DrawImage(0, 0, MakeImagePaintOnly(im)); draw.DrawImage(0, 0, MakeImagePaintOnly(im));
} }
else else
o.Paint(draw, sz); o.Paint(draw, sz, pi.context);
draw.End(); draw.End();
} }
i++; i++;

View file

@ -124,6 +124,17 @@ struct RichObjectType : Moveable<RichObjectType> {
virtual String GetClipFmts() const; virtual String GetClipFmts() const;
virtual String GetClip(const Value& data, const String& fmt) const; virtual String GetClip(const Value& data, const String& fmt) const;
virtual Size GetDefaultSize(const Value& data, Size maxsize, void *context) const;
virtual Size GetPhysicalSize(const Value& data, void *context) const;
virtual Size GetPixelSize(const Value& data, void *context) const;
virtual void Paint(const Value& data, Draw& w, Size sz, void *context) const;
virtual Image ToImage(const Value& data, Size sz, void *context) const;
virtual void Menu(Bar& bar, RichObject& ex, void *context) const;
virtual void DefaultAction(RichObject& ex, void *context) const;
virtual String GetLink(const Value& data, Point pt, Size sz, void *context) const;
Size StdDefaultSize(const Value& data, Size maxsize, void * context) const;
RichObjectType(); RichObjectType();
virtual ~RichObjectType(); virtual ~RichObjectType();
}; };
@ -153,8 +164,8 @@ public:
void SetSize(int cx, int cy) { size = Size(cx, cy); NewSerial(); } void SetSize(int cx, int cy) { size = Size(cx, cy); NewSerial(); }
void SetSize(Size sz) { size = sz; NewSerial(); } void SetSize(Size sz) { size = sz; NewSerial(); }
Size GetSize() const { return size; } Size GetSize() const { return size; }
void Paint(Draw& w, Size sz) const; void Paint(Draw& w, Size sz, void *context = NULL) const;
Image ToImage(Size sz) const; Image ToImage(Size sz, void *context = NULL) const;
Size GetPhysicalSize() const { return physical_size; } Size GetPhysicalSize() const { return physical_size; }
Size GetPixelSize() const { return pixel_size; } Size GetPixelSize() const { return pixel_size; }
Size GetDefaultSize(Size maxsize) const { return type ? type->GetDefaultSize(data, maxsize) : physical_size; } Size GetDefaultSize(Size maxsize) const { return type ? type->GetDefaultSize(data, maxsize) : physical_size; }
@ -177,8 +188,8 @@ public:
void SetYDelta(int yd) { ydelta = yd; } void SetYDelta(int yd) { ydelta = yd; }
int GetYDelta() const { return ydelta; } int GetYDelta() const { return ydelta; }
void Menu(Bar& bar) { if(type) type->Menu(bar, *this); } void Menu(Bar& bar, void *context = NULL) { if(type) type->Menu(bar, *this, context); }
void DefaultAction() { if(type) type->DefaultAction(*this); } void DefaultAction(void *context = NULL) { if(type) type->DefaultAction(*this, context); }
operator bool() const { return !IsNull(data); } operator bool() const { return !IsNull(data); }
@ -239,6 +250,7 @@ struct PaintInfo {
int highlightpara; int highlightpara;
Color highlight; Color highlight;
bool coloroverride; bool coloroverride;
void *context;
PaintInfo(); PaintInfo();
}; };

View file

@ -156,14 +156,15 @@ public:
int GetLength() const; int GetLength() const;
int GetTableCount() const; int GetTableCount() const;
void RemoveRow(int rowi);
void InsertRow(int rowi, const RichStyles& style);
private: private:
void Normalize0(); void Normalize0();
RichTable Copy(const Rect& sel) const; RichTable Copy(const Rect& sel) const;
void Paste(Point pos, const RichTable& tab); void Paste(Point pos, const RichTable& tab);
void RemoveRow0(int rowi); void RemoveRow0(int rowi);
void RemoveRow(int rowi);
void InsertRow(int rowi, const RichStyles& style);
void RemoveColumn0(int column); void RemoveColumn0(int column);
void RemoveColumn(int column); void RemoveColumn(int column);
void InsertColumn(int column, const RichStyles& style); void InsertColumn(int column, const RichStyles& style);

View file

@ -147,7 +147,6 @@ protected:
const RichTxt& GetConstText(int& pos) const; const RichTxt& GetConstText(int& pos) const;
RichTable& GetTable0(int table, bool update); RichTable& GetTable0(int table, bool update);
RichTable& GetUpdateTable(int table); RichTable& GetUpdateTable(int table);
const RichTable& GetConstTable(int table) const;
RichTxt& GetTableUpdateText(int table, const RichStyles& style, int& pi); RichTxt& GetTableUpdateText(int table, const RichStyles& style, int& pi);
void CombineFormat(FormatInfo& f, int pi, int pi2, bool& first, const RichStyles& style) const; void CombineFormat(FormatInfo& f, int pi, int pi2, bool& first, const RichStyles& style) const;
@ -202,7 +201,10 @@ public:
const RichTable& GetTable(int i) const; const RichTable& GetTable(int i) const;
int GetLength() const; int GetLength() const;
int GetTableCount() const; int GetTableCount() const;
const RichTable& GetConstTable(int table) const;
bool IsEmpty() const; bool IsEmpty() const;
RichCellPos GetCellPos(int table, int row, int column) const; RichCellPos GetCellPos(int table, int row, int column) const;

View file

@ -309,6 +309,8 @@ void RichTxt::GetRichPos(int pos, RichPos& rp, int ti, int maxlevel, const RichS
RichPara::Format RichTxt::GetFirstFormat(const RichStyles& style) const RichPara::Format RichTxt::GetFirstFormat(const RichStyles& style) const
{ {
if(part.IsEmpty())
return RichPara::Format();
if(IsTable(0)) { if(IsTable(0)) {
const RichTable& tab = GetTable(0); const RichTable& tab = GetTable(0);
return tab[0][0].text.GetFirstFormat(style); return tab[0][0].text.GetFirstFormat(style);

View file

@ -97,7 +97,7 @@ void Ide::SearchCode()
{ {
if(editor.navigator != AssistEditor::NAV_BROWSER) if(editor.navigator != AssistEditor::NAV_BROWSER)
editor.Navigator(AssistEditor::NAV_BROWSER); editor.Navigator(AssistEditor::NAV_BROWSER);
if(editor.browser.IsSearch()) if(editor.browser.search.HasFocus() && editor.browser.IsSearch())
editor.browser.ClearSearch(); editor.browser.ClearSearch();
else else
editor.browser.search.SetFocus(); editor.browser.search.SetFocus();

View file

@ -1 +1 @@
#define IDE_VERSION "902r181" #define IDE_VERSION "902r182"