void Print(Draw& w, const RichText& text, const Rect& page, const Vector<int>& pg) { LLOG("Print"); int lpage = text.GetHeight(page).page; PrintPageDraw pw(w); Size sz = w.GetPageMMs(); Size pgsz = page.Size(); int x = (6000 * sz.cx / 254 - pgsz.cx) / 2; int y = (6000 * sz.cy / 254 - pgsz.cy) / 2; for(int pi = 0; pi < pg.GetCount(); pi++) { int i = pg[pi]; w.StartPage(); w.Offset(x, y); pw.SetPage(i); PaintInfo paintinfo; paintinfo.top = PageY(i, 0); paintinfo.bottom = PageY(i + 1, 0); paintinfo.indexentry = Null; if(text.IsPrintNoLinks()) paintinfo.hyperlink = Null; text.Paint(pw, page, paintinfo); w.End(); String footer = text.GetFooter(); if(!IsNull(footer) && lpage) { String n = Format(footer, i + 1, lpage + 1); Size nsz = GetTextSize(n, Arial(90).Italic()); pw.Page(i).DrawText( x + pgsz.cx - nsz.cx, y + pgsz.cy + 100, n, Arial(90).Italic()); } w.EndPage(); } }
void RichQtfParser::EndPart() { if(istable) { if(paragraph.GetCount() == 0 && text.GetCount() == 0) if(table.GetCount()) table.Top().text.CatPick(pick(tablepart)); else target.CatPick(pick(tablepart)); else { paragraph.part.Clear(); text.Clear(); } } else { Flush(); bool b = paragraph.format.newpage; if(breakpage) paragraph.format.newpage = true; if(table.GetCount()) table.Top().text.Cat(paragraph, target.GetStyles()); else target.Cat(paragraph); paragraph.part.Clear();; paragraph.format.newpage = b; SetFormat(); breakpage = false; } istable = false; }
void DesertStrikeScenario::Minimap::mkInfoPanel( Resource &res, Inf &inf, Widget* panel ){ using namespace Tempest; const char* icon[][2] = { {"gui/icon/atack", "gui/item/shield"}, {"gui/heart", "gui/coin"} }; Widget *w = 0; for( int i=0; i<2; ++i ){ w = new Widget(); w->setMaximumSize( w->sizePolicy().maxSize.w, 25 ); w->setSizePolicy( Preferred, FixedMax ); w->setLayout( Horizontal ); for( int r=0; r<2; ++r ){ RichText * cost = new RichText(res); cost->setText(L"<s>123</s>"); BuyButton * btn = new BuyButton(res); btn->setMaximumSize(25); btn->icon = res.pixmap(icon[i][r]); w->layout().add( btn ); w->layout().add( cost ); inf.info[i][r] = cost; } panel->layout().add( w ); } }
RichText AsRichText(const wchar *s, const RichPara::Format& f) { RichText clip; RichPara p; p.format = f; p.part.Add().format = f; RichStyle cs; cs.format = f; cs.format.sscript = 0; cs.format.link.Clear(); cs.format.indexentry.Clear(); cs.format.language = LNG_ENGLISH; cs.format.label.Clear(); clip.SetStyle(f.styleid, cs); WString& part = p.part.Top().text; while(*s) { if(*s == '\n') { clip.Cat(p); part.Clear(); } if(*s >= 32 || *s == '\t') part.Cat(*s); s++; } clip.Cat(p); return clip; }
Size QTFDisplayCls::RatioSize(const Value& q, int cx, int cy) const { if(cy == 0 && cx > 0) { RichText txt = ParseQTF((String)q); txt.ApplyZoom(GetRichTextStdScreenZoom()); return Size(cx, txt.GetHeight(Zoom(1, 1), cx)); } return GetStdSize(q); }
void RichQtfParser::FlushStyles() { for(int i = 0; i < styleid.GetCount(); i++) if(stylenext[i] >= 0 && stylenext[i] < styleid.GetCount()) { RichStyle s = target.GetStyle(styleid[i]); s.next = styleid[stylenext[i]]; target.SetStyle(styleid[i], s); } }
Size QTFDisplayCls::GetStdSize(const Value& q) const { Size sz; RichText txt = ParseQTF((String)q); txt.ApplyZoom(GetRichTextStdScreenZoom()); sz.cx = txt.GetWidth(); sz.cy = txt.GetHeight(Zoom(1, 1), sz.cx); return sz; }
void DrawSmartText(Draw& draw, int x, int y, int cx, const char *text, Font font, Color ink, int accesskey) { if(*text == '\1') { RichText txt = ParseQTF(text + 1, accesskey); txt.ApplyZoom(GetRichTextStdScreenZoom()); txt.Paint(Zoom(1, 1), draw, x, y, cx); return; } DrawTLText(draw, x, y, cx, ToUnicode(text, CHARSET_DEFAULT), font, ink, accesskey); }
void SIC_GetQtfHeight(EscEscape& e) { int zoom = e.Int(0); e.CheckArray(0); String text = e[1]; int cx = e.Int(2); RichText doc; doc = ParseQTF(text);//!!!!! e = doc.GetHeight(Zoom(zoom, 1024), cx); }
RichText* RichText::create() { RichText* widget = new (std::nothrow) RichText(); if (widget && widget->init()) { widget->autorelease(); return widget; } CC_SAFE_DELETE(widget); return nullptr; }
RichText* RichText::create() { RichText* widget = new RichText(); if (widget && widget->init()) { CC_SAFE_AUTORELEASE(widget); return widget; } CC_SAFE_DELETE(widget); return NULL; }
Size GetSmartTextSize(const char *text, Font font, int cx) { if(*text == '\1') { Size sz; RichText txt = ParseQTF(text + 1); txt.ApplyZoom(GetRichTextStdScreenZoom()); sz.cx = min(cx, txt.GetWidth()); sz.cy = txt.GetHeight(Zoom(1, 1), sz.cx); return sz; } return GetTLTextSize(ToUnicode(text, CHARSET_DEFAULT), font); }
void QTFDisplayCls::Paint(Draw& draw, const Rect& r, const Value& v, Color ink, Color paper, dword style) const { String s; s << "[@(" << ink.GetR() << "." << ink.GetG() << "." << ink.GetB() << ") " << v; RichText rtext = ParseQTF(s); rtext.ApplyZoom(GetRichTextStdScreenZoom()); draw.DrawRect(r, paper); draw.Clipoff(r); rtext.Paint(Zoom(1, 1), draw, 0, 0, r.Width()); draw.End(); }
RichText RichEdit::ReplaceText() { RichText clip; RichPara p; formatinfo.ApplyTo(p.format); p.part.Add(); formatinfo.ApplyTo(p[0].format); p.part.Top().text = findreplace.replace.GetText(); clip.Cat(p); return clip; }
RichText* RichText::create() { RichText* widget = new RichText(); if (widget && widget->init()) { widget->autorelease(); return widget; } CC_SAFE_DELETE(widget); return NULL; }
void HeaderFooterDlg::Save(RichText& text) { if(use_header) text.SetHeaderQtf(header_editor.GetQTF()); else text.ClearHeader(); if(use_footer) text.SetFooterQtf(footer_editor.GetQTF()); else text.ClearFooter(); }
void StyleManager::Get(RichText& text) { SaveStyle(); for(int i = 0; i < dirty.GetCount(); i++) { Uuid id = dirty[i]; int q = style.Find(id); if(q >= 0) text.SetStyle(id, style.Get(id)); else text.RemoveStyle(id); } }
void CSDKClassInfoPanel::ApplySchemeSettings( IScheme *pScheme ) { RichText *pClassInfo = dynamic_cast<RichText*>(FindChildByName("classInfo")); if ( pClassInfo ) { pClassInfo->SetBorder(pScheme->GetBorder("NoBorder")); pClassInfo->SetBgColor(pScheme->GetColor("Blank", Color(0,0,0,0))); } BaseClass::ApplySchemeSettings( pScheme ); }
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; }
HelpPage() { Box *vbox = new VBox(); ScrollArea* scroll = new ScrollArea(); scroll->fitToParent(true); RichText *text = new RichText(help_text_html, help_text_html_len); scroll->virtualSize(Vec2(SCREEN_WIDTH,text->layout(SCREEN_WIDTH))); text->fitToParent(true); text->alpha(100); scroll->add(text,0,0); vbox->add( scroll, 0, 1 ); vbox->add( new Button(PROJECT_HOMEPAGE,Event::SELECT), 36, 0 ); m_content->add(vbox,0,0); }
HelpPage() { Box *vbox = new VBox(); ScrollArea* scroll = new ScrollArea(); scroll->fitToParent(true); RichText *text = new RichText(HELP_TEXT); scroll->virtualSize(Vec2(SCREEN_WIDTH,text->layout(SCREEN_WIDTH))); text->fitToParent(true); text->alpha(100); scroll->add(text,0,0); vbox->add( scroll, 0, 1 ); vbox->add( new Button("http://numptyphysics.garage.maemo.org",Event::SELECT), 36, 0 ); m_content->add(vbox,0,0); }
DesertStrikeScenario::Hint::Hint(Resource &res, Tempest::Widget *owner, Game &game) :ModalWindow(res,owner), game(game) { setLayout( Tempest::Vertical ); struct CPanel:Panel{ CPanel( Resource &res, Widget* ow ):Panel(res),owner(ow), closeRq(0){} void mouseDownEvent(Tempest::MouseEvent &e){ closeRq = 1; ppress = e.pos(); } void mouseDragEvent(Tempest::MouseEvent &e){ if( (e.pos()-ppress).manhattanLength()>15 ) closeRq = 0; } void mouseUpEvent(Tempest::MouseEvent &){ if( closeRq ) owner->deleteLater(); } void paintFrame( Tempest::Painter & p){ Panel::paintFrame(p); p.setColor(0,0,0,0.3); p.setBlendMode( Tempest::alphaBlend ); int sz = 8; p.drawRect( sz, sz, w()-sz*2, h()-sz*2 ); } Widget * owner; bool closeRq; Tempest::Point ppress; }; Panel *p = new CPanel(res, this); RichText * t = new RichText(res); t->setText( Lang::tr(L"$(desertstrike/tutorial/intro)") ); p->layout().add(t); p->setMargin(10); p->setMaximumSize(480, 300); p->setMinimumSize(480, 300); layout().add( new Widget ); layout().add( p ); layout().add( new Widget ); }
void SyncTopicFile(const RichText& text, const String& link, const String& path, const String& title) { LLOG("Scanning topic " << link); LTIMING("Scanning topic"); ClearLinkRef(link); ScanTopicIterator sti; sti.link = link; text.Iterate(sti); TopicInfo& ti = topic_info().GetPut(link); ti.title = title; ti.path = path; ti.time = FileGetTime(path); ti.words = sti.words.PickKeys(); FileOut out(TopicCacheName(path)); out << tdx_version << "\n"; out << title << '\n'; for(int i = 0; i < sti.ref.GetCount(); i++) out << sti.ref[i] << '\n'; out << '\n'; const Index<String>& ws = TopicWords(); for(int i = 0; i < ti.words.GetCount(); i++) out << ws[ti.words[i]] << '\n'; }
void StyleManager::Set(const RichText& text) { list.Clear(); int i; for(i = 0; i < text.GetStyleCount(); i++) list.Add(text.GetStyleId(i), text.GetStyle(i).name); list.Sort(1, RichEdit::CompareStyle); for(i = 0; i < text.GetStyleCount(); i++) { Uuid id = list.Get(i, 0); style.Add(id, text.GetStyle(id)); } int q = list.Find(RichStyle::GetDefaultId()); if(q >= 0) list.SetDisplay(q, 0, Single<RichEdit::DisplayDefault>()); ReloadNextStyles(); }
int GetSmartTextHeight(const char *s, int cx, Font font) { if(*s == '\1') { Size sz; RichText txt = ParseQTF(s + 1); txt.ApplyZoom(GetRichTextStdScreenZoom()); return txt.GetHeight(Zoom(1, 1), cx); } int cy = font.Info().GetHeight(); int h = cy; while(*s) { if(*s == '\n') h += cy; s++; } return h; }
void Report::Put(const RichText& txt, void *context) { PageY py(pagei, y); LLOG("Put RichText, py: " << py << ", pagerect: " << GetPageRect()); PaintInfo paintinfo; paintinfo.top = PageY(0, 0); paintinfo.bottom = PageY(INT_MAX, INT_MAX); paintinfo.indexentry = Null; paintinfo.hyperlink = Null; paintinfo.context = context; txt.Paint(*this, py, GetPageRect(), paintinfo); py = txt.GetHeight(py, GetPageRect()); LLOG("Final pos: " << py); Page(py.page); y = py.y; }
void Print(Draw& w, const RichText& text, const Rect& page) { int n = text.GetHeight(page).page; Vector<int> pg; for(int i = 0; i <= n; i++) pg.Add(i); Print(w, text, page, pg); }
void RichEdit::ApplyStylesheet(const RichText& r) { NextUndo(); SaveStylesUndo(); text.OverrideStyles(r.GetStyles(), false, false); ReadStyles(); Finish(); }
void RichEdit::InsertTable() { if(IsSelection()) return; WithCreateTableLayout<TopWindow> dlg; CtrlLayoutOKCancel(dlg, t_("Insert table")); dlg.header = false; dlg.columns <<= 2; dlg.columns.MinMax(1, 20); dlg.ActiveFocus(dlg.columns); if(dlg.Run() != IDOK) return; RichTable::Format fmt; int nx = minmax((int)~dlg.columns, 1, 20); for(int q = nx; q--;) fmt.column.Add(1); if(dlg.header) fmt.header = 1; RichTable table; table.SetFormat(fmt); for(int i = 0; i < (dlg.header ? 2 : 1); i++) for(int j = 0; j < nx; j++) { RichText h; h.SetStyles(text.GetStyles()); RichPara p; p.format = formatinfo; p.format.newpage = false; p.format.label.Clear(); h.Cat(p); table.SetPick(i, j, pick(h)); } NextUndo(); if(cursorp.posinpara) InsertLine(); if(text.GetRichPos(cursor).paralen) { InsertLine(); cursor = anchor = cursor - 1; begtabsel = false; } SaveFormat(cursor, 0); AddUndo(new UndoCreateTable(text.SetTable(cursor, table))); Finish(); }
void DashEdit::SetData(const Value& data) { RichText text; String d = data; RichPara para; RichPara::Format f; for(const char *s = d; *s; s++) if(*s == '\n') { text.Cat(para); para.part.Clear(); } else if(*s == '~') f.dashed = !f.dashed; else if((byte)*s >= ' ') para.Cat(String(*s, 1).ToWString(), f); text.Cat(para); Pick(text); }